
#import <Foundation/Foundation.h>
#import "TalkfunSDKLifeLiveConfig.h"
#import "TalkfunCloudLiveSDK.h"
#import "TalkfunSDK.h"
NS_ASSUME_NONNULL_BEGIN
//SDK代理
@protocol TalkfunRtcEngineKitDelegate <NSObject>

/**@name 进入房间的事件回调
 * - 如果加入成功，code 会是一个正数（code = 0），代表加入房间成功）。
 * - 如果加入失败，code 会是一个负数（code < 0），代表进房失败的错误码。
 *  调用刷新refreshData: 也会重新回调
 *  进房失败的错误码含义请参见[错误码  TalkfunSDK 文件的TalkfunError 枚举
 */
- (void)onEnterRoom:(NSInteger)code result:(TFError*)error;
/** @name 当前用户进入房间触发
     详见 TFMember.h 中的定义
*/
- (void)onMemberJoinMe:(TFMember*)result;
/** @name 其它人进入房间触发
     详见 TFMember.h 中的定义
*/
- (void)onMemberJoinOther:(TFMember*)result;
/** @name 有人退出房间
     详见 TFMember.h 中的定义
*/
- (void)onMemberLeave:(TFMember*)result;
/**
 @name 同时在线人数  (真实人+虚拟人员 的总数)
*/
- (void)onPeakConcurrentUsers:(NSInteger)total;
/** @name 接收别人的聊天事件回调
    详见 TFChatSend.h 中的定义
 */
- (void)onDidReceiveText:(TFChatData*)result;
/** @name 删除聊天事件回调
 */
- (void)onChatDel:(NSString*)uuid;
/** @name 更新了机器人成员列表*/
- (void)onCustomerServiceListUpdate:(NSMutableArray<TFMember *>*)robotList;
/*
 允许连麦
 */
- (void)rtcUp:(TalkfunRtcModel*)model;
/*
 主动取消连麦
 */
- (void)rtcDown:(TalkfunRtcModel*)model;
/*
 被踢除连麦
 */
- (void)rtcKick:(TalkfunRtcModel*)model;

/*
 用户离线
 */
- (void)rtcOffline:(TalkfunRtcModel*)model;

/*
 打开摄像头
 */
- (void)rtcOpenVideo:(TalkfunRtcModel*)model;
/*
 关闭摄像头
 */
- (void)rtcCloseVideo:(TalkfunRtcModel*)model;
/*
打开麦克风
*/
-(void)rtcOpenAudio:(TalkfunRtcModel*)model;
/*
关闭麦克风
*/
-(void)rtcCloseAudio:(TalkfunRtcModel*)model;
/*
   报告扬声器的音频音量指示
*/
- (void)rtcReportAudioVolumeIndicationOfSpeakers:(NSMutableArray<TalkfunRtcModel *>*)list;
/*
   已连麦人员打开涂鸦权限
*/
-(void)rtcDrawEnable:(TalkfunRtcModel*)model;
/*
   已连麦人员关闭涂鸦权限
*/
-(void)rtcDrawDisable:(TalkfunRtcModel*)model;
/*
  未连麦人员打开涂鸦权限
*/
-(void)onMemberDrawEnable:(TFMember*)model;
/*
  未连麦人员关闭涂鸦权限
*/
-(void)onMemberDrawDisable:(TFMember*)model;
/*
申请连麦
*/
-(void)rtcApply:(TFMember*)result;
/*
 取消申请连麦
*/
-(void)rtcCancelApply:(TFMember*)result;
/*
 用户拒绝连麦
*/
- (void)rtcReject:(TFMember*)result;
/*
 rtc跟服务器的连接断开
 */
-(void)rtcEngineConnectionDidInterrupted;
/*rtc跟服务器的连接恢复*/
-(void)rtcDidRejoinChannel;
/**连麦功能开启*/
-(void)onRtcStart;
/**连麦功能关闭*/
-(void)onRtcStop;
/**
 @name 推送公告的事件回调
*/
- (void)onAnnouncement:(TFAnnouncement*)result;
/** @name 接收滚动通知事件回调
    详见 TFAnnounceRoll.h 中的定义
 */
- (void)onAnnounceRoll:(TFAnnounceRoll*)result;
/**
   @name 广播
*/
- (void)onBroadcast:(TFBroadcast*)result;
/**
 @name  账号在多端登录相互挤下线
*/
- (void)onMemberForceout;
/**
 @name 主播被踢出房间的事件回调
*/
- (void)onMemberKick;
/**
 @name 课程超时
*/
- (void)onCourseExpire;
/**
 @name 用户响应抢答
*/
- (void)onResponder:(TFMember*)member;
/*
奖励
*/
//-(void)rtcAward:(TalkfunRtcModel*)model;
/**
* @画板载入课件
*/
- (void)loadCourseware;
/**
 @name 已直播时长
*/
- (void)onLiveDuration:(TFLiveDuration*)result;
/** @name 接收别人发送的花朵
 */
- (void)onFlowerSend:(TFLiveFlowerData*)result;
/**
 @name  监听机器人标签
*/
- (void)onUserTagShow:(TFuserTagShow*)result;
/**
 @name 课程冲突
*/
- (void)onCourseConflict:(TFcourseConflict*)result;
@optional

@end
@interface TalkfunRtcEngineKit : NSObject

/*
 课程数据
 onEnterRoom:result:()回调后, roomInfo的值才准确
 */
@property (nonatomic,strong)TFRtcEngineKitRoomInfo * _Nullable roomInfo;

/*设置代理*/
@property (nonatomic,weak) id<TalkfunRtcEngineKitDelegate> _Nullable delegate;
/** 设置布局模式
 * streamMode：
 * 1 多人合流模式，不自动上讲台
 * 2 双人合流模式，不自动上讲台
 * 3 多人合流模式，自动上讲台
 * 4 双人合流模式，自动上讲台
 */
@property(nonatomic,assign)NSInteger  streamMode;//只能一个人在讲台上,用于新的局部
/**设置rtc视频支持方向*/
@property (nonatomic, assign )TalkfunVideoOutputOrientationMode orientationMode;
/**设置视频播放模式 默认TalkfunMovieScalingModeNone*/
@property(nonatomic,assign) TalkfunMovieScalingMode scalingMode;

/**获取讲台状态*/
@property(nonatomic,assign)TalkfunRTCStatus  RTCStatus;

/**获取直播状态*/
@property (nonatomic,assign) TalkfunRTCLiveState liveState;

// 课程是否有效的认证
- (TalkfunRtcEngineKit*)initWithCourseID:(NSString *)courseID  ;

/**
 *  监听事件，处理回调数据
 *
 *  监听事件，event为事件名，获取的数据在回调的callback里面
 **/
- (void)on:(NSString *)event callback:(void (^)(id obj))callback;


/**
 *  触发某个事件(有回调)
 */
- (void)emit:(NSString *)event params:(id)params callback:(void (^)(id result))callback;

/**
 *  开始直播
 */
- (void)startLive:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/**结束直播*/
- (void)stopLive:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;


/**开启讲台*/
- (void)openRtc:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/**关闭*/
- (void)closeRtc:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/**前后摄像头切换*/
- (void)switchCamera;

/**获取本地摄像头状态**/
- (BOOL)getVideoState;
/**:   打开摄像头, */
- (void)openVideo:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/**获取本地麦克风状态**/
- (BOOL)getAudioState;
/**:   关闭摄像头*/
- (void)closeVideo:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/**:   关闭所有摄像头*/

- (void)closeAllCamera:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/**:   开启所有摄像头*/

- (void)openAllCamera:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/**:   关闭所有麦克风*/
- (void)closeAllAudio:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/**:   开启所有麦克风*/
- (void)openAllAudio:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/**   打开麦克风*/
- (void)openAudio:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/**   关闭麦克风*/
- (void)closeAudio:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/**  打开涂鸦*/
- (void)giveDrawPower:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/** 关闭涂鸦*/
- (void)cancelDrawPower:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;

/** 邀请连麦*/
- (void)giveInvite:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/** 取消邀请连麦*/
- (void)cancelInvite:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/** 拒绝用户申请连麦*/
- (void)rejectApply:(NSString*)xid  callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;
/** 奖励*/
- (void)award:(TFInteractiveToolAwardParams*)params callback:(void (^__nullable)(NSInteger code ,TFInteractiveToolAwardData *data,TFError *_Nullable  error))callback;


/**获取学员列表用户奖励分数*/
- (void)getAwardList:(void (^)(NSInteger code ,NSMutableArray <TFInteractiveToolAwardData *>*_Nullable  list,TFError *_Nullable  error))callback;
/**
 公告
 */
-(void)sendAnnouncement:(NSString *)message callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**
 通知
 */
-(void)sendNotice:(TFNoticeParams *)model callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**
 广播
 */
- (void)sendBroadCast:(TFBroadCastParams *_Nullable)model callback:(void (^_Nullable)(NSInteger code ,TFError * _Nullable  error))callback;
/**
 点名列表
 */
-(void)getRollRecordList:(void (^_Nullable)(NSInteger code, NSMutableArray<TFRtcEngineKitRollList *> * _Nullable list ,TFError * _Nullable  error))callback;

/**
 发起点名
 startTime:秒数
 */
-(void)startRoll:(NSInteger)startTime callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**
 查看点名详情
 */

-(void)checkRollDetail:(TFRollParams *)model callback:(void (^_Nullable)(NSInteger code, TFRtcEngineKitSignNews* _Nullable  result ,TFError * _Nullable  error))callback;

/**
 结束点名
 signID:点名ID
 */
-(void)endRoll:(NSString *)signID callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**
 抽奖记录
 */

-(void)getLotteryList:(void (^_Nullable)(NSInteger code, NSMutableArray<TFRtcEngineKitLottery *> * _Nullable list ,TFError * _Nullable  error))callback;

/**
 抽奖开始
 */
-(void)startLottery:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;
/**
 结束抽奖
 count:抽奖的人数
 */
-(void)stopLottery:(NSString *)count callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;
/**
 投票列表
 */
-(void)getVoteList:(void (^_Nullable)(NSInteger code, NSMutableArray<TFRtcEngineKitVote *> * _Nullable list ,TFError * _Nullable  error))callback;

/**
 删除投票
 vid:投票ID
 */
-(void)deleteVote:(NSString *_Nonnull)vid callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**
 查看投票详情
 vid:投票ID
 */
-(void)checkVoteDetail:(NSString *_Nonnull)vid callback:(void (^_Nullable)(NSInteger code, TFRtcEngineKitVoteEmit* _Nullable  result ,TFError * _Nullable  error))callback;

/**
 结束投票
 vid:投票ID

 */
-(void)endVote:(NSString *_Nonnull)vid andisPublic:(BOOL)ispublic callback:(void (^_Nullable)(NSInteger code, TFError * _Nullable  error))callback;

/**
 已保存,然后发起投票
 vid:投票ID
 */
-(void)publishSavedVote:(NSString *)vid callback:(void (^_Nullable)(NSInteger code, TFError * _Nullable  error))callback;

/**
保存投票
 */
-(void)saveVote:(TFVoteParams *_Nonnull)model callback:(void (^_Nullable)(NSInteger code, NSString* _Nullable  vid ,TFError * _Nullable  error))callback;

/**
 添加投票
 */
-(void)publishVote:(TFVoteParams *_Nonnull)model callback:(void (^_Nullable)(NSInteger code, NSString* _Nullable  vid ,TFError * _Nullable  error))callback;


///**互动工具--抢答器配置*/
- (void)responderConfiguration:(TFInteractiveToolResponderParams*)status callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

///**互动工具--定时器配置*/
- (void)timerConfiguration:(TFInteractiveToolTimeParams*)params callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/*
 转盘应用
*/
- (void)turntableApplicate:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;
/* 转盘开始
*/
- (void)turntableStart:(TFTurntableParams*)params callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**转盘关闭 */
- (void)turntableStop:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;

/**
 *   允许上讲台的申请
 **/
- (void)up:(NSString*)xid  callback:(void (^__nullable) (NSInteger code ,TFError *_Nullable  error))callback;

/**
 *   踢下讲台
 **/
- (void)kick:(NSString*)xid  callback:(void (^__nullable) (NSInteger code ,TFError *_Nullable  error))callback;

//美颜
- (void)setBeautyEffectOptions:(BOOL)enable ;

/**
 *  静音/取消静音所有用户的声音
 *
 * @param mute YES：静音；NO：取消静音
 *
 * @note 静音时会停止接收所有用户的远端音频流并停止播放，取消静音时会自动拉取所有用户的远端音频流并进行播放。
 */
- (void)muteAllRemoteAudio:(BOOL)mute;
/**
 镜像 ,NO为镜像,YES不镜像
 */
-(void)setLocalViewMirror:(BOOL)mirror;


/**单例*/
+ (TalkfunRtcEngineKit *)shareInstance;

/** 进入房间
 *  调用  enterRoom() 接口执行进房操作后，会收到来自 SDK 的 onEnterRoom:result:() 回调：
 * @param param 进房参数，请参考 TFRtcEngineKitInitParams
*/
- (void)enterRoom:(TFRtcEngineKitInitParams *_Nullable)param;

/**
 *   踢出房间
 **/
- (void)memberKick:(NSString*)xid  callback:(void (^__nullable) (NSInteger code ,TFError *_Nullable  error))callback;
/**
 *   禁言
 **/
- (void)chatDisable:(NSString*)xid  callback:(void (^__nullable) (NSInteger code ,TFError *_Nullable  error))callback;
/**
 *   解除禁言
 **/
- (void)chatEnable:(NSString*)xid  callback:(void (^__nullable) (NSInteger code ,TFError *_Nullable  error))callback;
/**
 *   全体禁言
 **/
- (void)chatEnableAll:(BOOL)status callback:(void (^__nullable)(NSInteger code ,TFError *_Nullable  error))callback;


/**
   切换课件模式
 */
-(void)setPageMode:(TalkfunPageMode)mode callback:(void (^_Nullable)(NSInteger code,TFError * _Nullable  error))callback;



//所有在线学员数据
- (void)allStudents:(void (^)(NSArray* result))callback;
//在线学生数据 2.0
- (void)getUserList:(TFMemberParams *)params  callback:(void (^__nullable)(NSInteger code ,NSMutableArray <TFMember *>*_Nullable  list ,TFError *_Nullable  error))callback;


//所有在线人员数据
- (void)getMemberList:(void (^)(NSArray* result))callback;
//所有在线人员数据 2.0
- (void)getMemberList:(TFMemberParams *)params  callback:(void (^__nullable)(NSInteger code ,NSMutableArray <TFMember *>*_Nullable  list ,TFError *_Nullable  error))callback;



/**获取申请上讲台的列表*/
-(NSArray*)getRtcApplyList;
/**获取申请上讲台的列表   2.0  优化*/
-(NSArray<TFMember *>*)optimized_getRtcApplyList;


/**获取邀请上讲台的列表*/
-(void)getInviteList:(void (^)(NSArray *array))callback;
/**获取邀请上讲台的列表   2.0   优化*/
-(void)optimized_getInviteList:(void (^_Nullable)(NSInteger code, NSMutableArray<TFMember *> * _Nullable list ,TFError * _Nullable  error))callback;


/**讲台上的用户列表*/
- (NSArray*)getRtcUserEntityList NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, "该方法已过期,请使用optimized_getRtcUserEntityList") ;
/**在讲台上的数据        2.0     优化*/
- (NSArray<TalkfunRtcModel *>*)optimized_getRtcUserEntityList;
/**
  发送聊天 2.0
  result result = 0 成功），result != 0 时为错误码。
 */
- (void)sendChat:(NSString *_Nullable)msg callback:(void (^__nullable) (NSInteger code,  TFChatData*_Nullable  model ,TFError *_Nullable  error))callback;
/**
 *上传聊天图片
 *
 *uploadProgress    0 - 1
  如果发送成功，code 会是0        error 等于nill    imageUrl 会有值
  如果发送失败，code 会是!=0    error会有值
 **/
- (void)uploadingpicImg:(UIImage*_Nonnull)image  progress:(nullable void (^)(CGFloat  uploadProgress))uploadProgress callback:(void (^__nullable)(NSInteger code , NSString *_Nullable model,TFError *_Nullable  error))callback;
/**
 *投票上传照片
 *
 *uploadProgress    0 - 1
  如果发送成功，code 会是0        error 等于nill    imageUrl 会有值
  如果发送失败，code 会是!=0    error会有值
 **/

-(void)uploadPicture:(UIImage *)image progress:(nullable void (^)(CGFloat  uploadProgress))uploadProgress callback:(void (^__nullable)(NSInteger code , NSString *_Nullable imageUrl,TFError *_Nullable  error))callback;




//微信分享信息
-(void)setWXShare:(void (^__nullable) (NSInteger code,  TalkfunWXShareParams*_Nullable  model ,TFError *_Nullable  error))callback;
//分享海报
-(void)setWXPoster:(void (^__nullable) (NSInteger code,  NSString*_Nullable  urlPoster ,TFError *_Nullable  error))callback;

/**
 *  重新加载SDK
 **/
- (void)reload;
/**
 *  销毁(退出控制器时调用)
 */
- (void)destroy;
@end

NS_ASSUME_NONNULL_END
